﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true"
    CodeFile="ThietLapMuaBaoHiemNhanVien.aspx.cs" Inherits="ThietLapMuaBaoHiemNhanVien" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script language="javascript" type="text/javascript">
        function calculate() {
            var tong = document.getElementById("<%=txtluongcoban.ClientID %>").value;
            var bi = document.getElementById("<%=txtphucap.ClientID %>").value;
            var phantrambaohiem = document.getElementById("<%=txtphantrambaohiem.ClientID %>").value;
            var phantramcongtynop = document.getElementById("<%=txtphantramcongty.ClientID %>").value;
            var phantramnguoinop = document.getElementById("<%=txtphantramnguoilaodong.ClientID %>").value;
            if (tong == '') tong = "0";
            if (bi == '') bi = "0";
            if (phantrambaohiem == '') phantrambaohiem = "0";
            if (phantramcongtynop == '') phantramcongtynop = "0";
            if (phantramnguoinop == '') phantramnguoinop = "0";
            tong = tong.replace(',', '').replace(',', '').replace(',', '');
            bi = bi.replace(',', '').replace(',', '').replace(',', '');

            var t1 = parseFloat(tong);
            var t2 = parseFloat(bi);
            var phantrambaohiem1 = parseFloat(phantrambaohiem);
            var phantramcongtynop1 = parseFloat(phantramcongtynop);
            var phantramnguoinop1 = parseFloat(phantramnguoinop);
            document.getElementById("<%=txttongluong.ClientID %>").value = ((t1 + t2)).toFixed(0).replace(/\d(?=(\d{3})+\.)/g, '$&,');
            document.getElementById("<%=txtthanhtienbaohiem.ClientID %>").value = ((t1 + t2) * phantrambaohiem1 / 100).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
            document.getElementById("<%=txtthanhtiencongtynop.ClientID %>").value = ((t1 + t2) * (phantrambaohiem1/100) * (phantramcongtynop1/100)).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
            document.getElementById("<%=txtthanhtiennguoilaodongnop.ClientID %>").value = ((t1 + t2) * (phantrambaohiem1/100) * (phantramnguoinop1 / 100)).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
        }

        
       
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:UpdatePanel ID="up1" runat="server">
        <ContentTemplate>
            <div class="panel panel-success margin">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        Quản lý mua bảo hiểm nhân viên</h3>
                </div>
                <div class="panel-body">
                    <table width="100%">
                        <tr>
                            <td>
                                Họ tên<br />
                                <asp:DropDownList ID="dlnhanvien" DataValueField="IDs" DataTextField="hoten" runat="server"
                                    CssClass="form-control with98">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator1" runat="server"
                                    ControlToValidate="dlnhanvien" ErrorMessage="Chọn nhân viên" Display="None" Text="*"></asp:RequiredFieldValidator>
                            </td>
                            <td width="10%">
                                Lương cơ bản<br />
                                <asp:TextBox runat="server" CssClass="form-control " onchange="calculate()" ID="txtluongcoban">
                                </asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender9" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtluongcoban" ValidChars=",." />
                            </td>
                            <td width="10%">
                                Phụ cấp<br />
                                <asp:TextBox runat="server" onchange="calculate()" CssClass="form-control " ID="txtphucap">
                                </asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender10" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtphucap" ValidChars=",." />
                            </td>
                            <td width="10%">
                                Tổng lương<br />
                                <asp:TextBox runat="server" CssClass="form-control " ID="txttongluong">
                                </asp:TextBox>
                            </td>
                            <td width="10%">
                                Đơn vị bán bảo hiểm<br />
                                <asp:DropDownList ID="dlBenBanBH" DataValueField="IDs" DataTextField="TenNCC" runat="server"
                                    CssClass="form-control with98">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ValidationGroup="Them" ID="RequiredFieldValidator2" runat="server"
                                    ControlToValidate="dlBenBanBH" ErrorMessage="Chọn bên bán bảo hiểm" Display="None"
                                    Text="*"></asp:RequiredFieldValidator>
                            </td>
                            <td width="10%">
                                % bảo hiểm<br />
                                <asp:TextBox runat="server" CssClass="form-control " onchange="calculate()" ID="txtphantrambaohiem">
                                </asp:TextBox>
                                
                            </td>
                            <td width="10%">
                                Thành tiền bảo hiểm<br />
                                <asp:TextBox ID="txtthanhtienbaohiem" CssClass="form-control " runat="server"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtthanhtienbaohiem" ValidChars=",." />
                            </td>
                            </tr>
                        <tr>
                            <td width="10%">
                                % công ty nộp<br />
                                <asp:TextBox ID="txtphantramcongty" CssClass="form-control " runat="server" onchange="calculate()"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtphantramcongty" ValidChars=",." />
                            </td>
                        
                            <td width="10%">
                                % người lao động nộp<br />
                                <asp:TextBox ID="txtphantramnguoilaodong" onchange="calculate()"  CssClass="form-control " runat="server"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtphantramnguoilaodong" ValidChars=",." />
                            </td>
                            <td>
                                Thành tiền công ty nộp<br />
                                <asp:TextBox ID="txtthanhtiencongtynop"  CssClass="form-control " runat="server"></asp:TextBox>
                                
                            </td>
                            <td width="10%">
                                TT người lao động nộp<br />
                                <asp:TextBox ID="txtthanhtiennguoilaodongnop" CssClass="form-control " runat="server" onchange="chietkhau()"></asp:TextBox>
                                
                            </td>
                           
                            <td width="10%">
                                Từ ngày<br />
                                <asp:TextBox runat="server" CssClass="form-control " ID="txtTuNgay">
                                </asp:TextBox>
                                <cc1:CalendarExtender PopupPosition="BottomRight" ID="CalendarExtender6" runat="server"
                                    TargetControlID="txtTuNgay" Format="dd/MM/yyyy">
                                </cc1:CalendarExtender>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender7" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtTuNgay" ValidChars="/" />
                            </td>
                            <td width="10%">
                                <span style="margin-left: 5px;">Đến ngày</span>
                                <br />
                                <asp:TextBox runat="server" CssClass="form-control " ID="txtDenNgay">
                                </asp:TextBox>
                                <cc1:CalendarExtender PopupPosition="BottomRight" ID="CalendarExtender7" runat="server"
                                    TargetControlID="txtDenNgay" Format="dd/MM/yyyy">
                                </cc1:CalendarExtender>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender8" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtDenNgay" ValidChars="/" />
                            </td>
                            <td width="14%">
                                <br />
                                <asp:CheckBox ID="ckDaTra" runat="server" Text="Đã trả" AutoPostBack="true"
                                    oncheckedchanged="ckDaTra_CheckedChanged" />
                            
                                <asp:CheckBox ID="ckDaThu" runat="server" Text="Đã thu lại" AutoPostBack="true"
                                    OnCheckedChanged="ckDaThu_CheckedChanged" />
                            </td>
                            
                        </tr>
                        <tr>
                         
                         <td width="10%">
                                Ngày nộp bảo hiểm<br />
                                <asp:TextBox ID="txtngaythang" Enabled="false" CssClass="form-control " runat="server"></asp:TextBox>
                                 <cc1:CalendarExtender PopupPosition="BottomRight" ID="CalendarExtender1" runat="server"
                                    TargetControlID="txtngaythang" Format="dd/MM/yyyy">
                                </cc1:CalendarExtender>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender4" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtngaythang" ValidChars="/" />
                            </td>
                            <td>
                                Hình thức thanh toán
                                <asp:DropDownList ID="drhinhthucthanhtoan" CssClass="form-control" runat="server" Enabled="false"
                                    Visible="true">
                                    <asp:ListItem Value="0" Text="Chọn hình thức thanh toán"></asp:ListItem>
                                    <asp:ListItem Value="1" Text="Ngân hàng"></asp:ListItem>
                                    <asp:ListItem Value="2" Text="Tiền mặt"></asp:ListItem>
                                    
                                </asp:DropDownList>
                               
                            </td>
                            <td>
                                <asp:Label ID="Label2" runat="server" Enabled="false" Visible="true">  Tài khoản</asp:Label><br />
                                <asp:DropDownList ID="drtaikhoan" Visible="true" Width="200px" DataTextField="TaiKhoan" Enabled="false"
                                    DataValueField="IDs" CssClass="form-control" runat="server">
                                </asp:DropDownList>
                            </td>
                             <td width="10%">
                                Ngày thu<br />
                                <asp:TextBox ID="txtngaythu"  CssClass="form-control " Enabled="false" runat="server"></asp:TextBox>
                                 <cc1:CalendarExtender PopupPosition="BottomRight" ID="CalendarExtender2" runat="server"
                                    TargetControlID="txtngaythu" Format="dd/MM/yyyy">
                                </cc1:CalendarExtender>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender5" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtngaythu" ValidChars="/" />
                            </td>
                            <td width="10%">
                            <%-- Đơn vị nhận tiền bảo hiểm   <br />--%>
                                
                                 <asp:DropDownList ID="drkhach" Visible="false" DataValueField="IDs" DataTextField="tenkhachhang" runat="server"
                                    CssClass="form-control with98">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="7">
                                <asp:Button ID="btnSave" ValidationGroup="Them" runat="server" Style="margin-left: 5px;"
                                    Text="Lưu lại" CssClass="btn btn-primary" OnClick="btnSave_Click" />
                                <asp:Button ID="btncapnhat" runat="server" Text="Cập nhật" CssClass="btn btn-info"
                                    Visible="false" OnClick="btncapnhat_Click" />
                                <asp:Button ID="btnCancel" runat="server" Text="Nhập mới" CssClass="btn btn-warning"
                                    OnClick="btnCancel_Click" />
                            </td>
                        </tr>
                    </table>
                    <asp:ValidationSummary ID="ValidationSummary1" HeaderText="Bạn phải nhập các trường sau:"
                        ShowMessageBox="true" ValidationGroup="Them" ShowSummary="false" EnableClientScript="true"
                        runat="server" />
                </div>
            </div>
            <div style="margin: 5px;">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        Danh sách mua bảo hiểm nhân viên
                    </div>
                     <div class="panel-heading">
                      

                        <asp:DropDownList ID="DropDownList2" DataValueField="IDs" DataTextField="hoten" runat="server" Width="200px"
                                    CssClass="form-control with98">
                                </asp:DropDownList>
                                 <asp:Button ID="btnXem" runat="server" Text="Tìm kiếm" 
                             CssClass="btn btn-primary" onclick="btnXem_Click"
                             />
                        <asp:Button ID="btnPrint" runat="server" Text="Xuất báo cáo" CssClass="btn btn-primary"
                            OnClick="btnPrint_Click" />
                    </div>
                    <div style="width: 100%; margin-top: 10px; overflow: auto;" class="wrapper">
                        <div style="width: 100%; max-height: 300px;">
                            <asp:GridView ID="GV" runat="server" AutoGenerateColumns="false" BackColor="White"
                                BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="1" EmptyDataText="Không có dữ liệu nào"
                                EnableModelValidation="True" ShowFooter="false" CssClass="form-control withall"
                                Width="1800px" OnRowCommand="GV_RowCommand">
                                <Columns>
                                    <asp:TemplateField HeaderText="Xóa" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50px"
                                        ItemStyle-Width="50px">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="lbXoa" runat="server" Width="20px" Height="20px" ImageUrl="~/img/delete-24.png"
                                                OnClientClick="return confirm('Bạn chắc chắn muốn xóa ?')" CommandArgument='<%#Eval("IDs")%>'
                                                Text="Xóa" CommandName="Del" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Sửa" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50px"
                                        ItemStyle-Width="50px">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="lbSua" runat="server" Width="15px" Height="15px" ImageUrl="~/img/edit.ico"
                                                CommandArgument='<%#Eval("IDs")%>' Text="Sửa" CommandName="Select" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="hoten" ItemStyle-CssClass="padding" HeaderText="Họ tên"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                    <asp:BoundField DataField="luongcoban" DataFormatString="{0:0,0}" ItemStyle-CssClass="padding" HeaderText="Lương cơ bản"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                    <asp:BoundField DataField="phucap" DataFormatString="{0:0,0}" ItemStyle-CssClass="padding" HeaderText="Phụ cấp"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                    <asp:BoundField DataField="phantrambaohiem" ItemStyle-CssClass="padding" HeaderText="% bảo hiểm"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                    <asp:BoundField DataField="thanhtienbaohiem" ItemStyle-CssClass="padding" HeaderText="Thành tiền bảo hiểm"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:0,0}" />
                                    <asp:BoundField DataField="phantramcongtynop" ItemStyle-CssClass="padding" HeaderText="% Công ty nộp"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                    <asp:BoundField DataField="thanhtiencongtynop" ItemStyle-CssClass="padding" HeaderText="TT công ty nộp"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:0,0}" />
                                    <asp:BoundField DataField="PhanTramNhanVienNop" ItemStyle-CssClass="padding" HeaderText="% nhân viên nộp"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:0,0}" />
                                    <asp:BoundField DataField="thanhtiennhanviennop" ItemStyle-CssClass="padding" HeaderText="TT nhân viên nộp"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                    <asp:BoundField DataField="tenncc" ItemStyle-CssClass="padding" HeaderText="Bên bán bảo hiểm"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left"  />
                                    <asp:BoundField DataField="ngaynop" ItemStyle-CssClass="padding" HeaderText="Ngày nộp"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                    <asp:BoundField DataField="ngaythu" ItemStyle-CssClass="padding" HeaderText="Ngày thu"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                          <asp:BoundField DataField="hinhthuc" ItemStyle-CssClass="padding" HeaderText="Hình thức trả"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                        <asp:BoundField DataField="taikhoan" ItemStyle-CssClass="padding" HeaderText="Tài khoản"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                    <asp:BoundField DataField="datra" ItemStyle-CssClass="padding" HeaderText="Đã trả BH"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                    <asp:BoundField DataField="dathu" ItemStyle-CssClass="padding" HeaderText="Đã thu"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                        <asp:BoundField DataField="tungay" ItemStyle-CssClass="padding" HeaderText="Từ ngày"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                        <asp:BoundField DataField="denngay" ItemStyle-CssClass="padding" HeaderText="Đến ngày"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
                                </Columns>
                                <FooterStyle BackColor="White" ForeColor="#000066" Font-Bold="True" HorizontalAlign="Left" />
                                <HeaderStyle BackColor="White" Font-Bold="True" ForeColor="Black" Height="30px" />
                                <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                                <RowStyle BackColor="White" ForeColor="#000066" Height="30px" />
                                <SelectedRowStyle BackColor="Lavender" Font-Bold="false" />
                            </asp:GridView>
                        </div>
                    </div>
                </div>
                <asp:HiddenField ID="hdID" runat="server" />
                <asp:HiddenField ID="hdatra" runat="server" />
                <asp:HiddenField ID="hdathu" runat="server" />
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:PostBackTrigger ControlID="btnPrint" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
